package com.unswift.exception;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.unswift.annotation.api.Api;
import com.unswift.annotation.api.ApiConstructor;
import com.unswift.annotation.api.ApiField;

@SuppressWarnings("serial")
@Api(value="宇燕核心异常类", author="unswift", date="2023-04-08", version="1.0.0")
public class CoreException extends RuntimeException {
	
	@ApiField("日志对象")
	private static final Logger logger=LoggerFactory.getLogger(CoreException.class);
	
	@ApiField("异常编码")
	private String code;
	
	@ApiConstructor(value="核心异常类构造", params={@ApiField("异常编码"), @ApiField("异常消息")})
	public CoreException(String code, String message) {
		super(message);
		this.code=code;
	}

	@ApiConstructor(value="核心异常类构造", params={@ApiField("异常编码"), @ApiField("异常消息"), @ApiField("异常")})
	public CoreException(String code, String message, Throwable e) {
		super(message, e);
		this.code=code;
		logger.error(message, e);
	}

	public String getCode() {
		return code;
	}
}
